package com.yxx.controller;

import com.yxx.annotation.VisitLogger;
import com.yxx.entityModel.vo.Result.ResponseResult;
import com.yxx.entityModel.vo.response.BlogBackInfoResponse;
import com.yxx.entityModel.vo.response.BlogInfoResponse;
import com.yxx.service.BlogInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 博客首页接口
 * @author yuxiangxun
 * @date 2025/1/21
 * @apiNote
 */
@Slf4j
@RestController
@Api(tags = "博客")
public class BlogInfoController {

    @Resource
    private BlogInfoService blogInfoService;

    /**
     * 上传访客信息
     */
    @PostMapping("/report")
    @ApiOperation(value = "上传访客信息")
    public ResponseResult<?> report(){
        blogInfoService.report();
        return ResponseResult.success();
    }

    /**
     * 查看博客信息
     * @return
     */
    @ApiOperation(value = "查看博客信息")
    @GetMapping("/")
    public ResponseResult<BlogInfoResponse> getBlogInfo(){
        return ResponseResult.success(blogInfoService.getBlogInfo());
    }

    /**
     * 查看后台信息
     * @return
     */
    @GetMapping("/admin")
    @ApiOperation(value = "查看后台信息")
    public ResponseResult<BlogBackInfoResponse> getBlogBackInfo(){
        return ResponseResult.success(blogInfoService.getBlogBackInfo());
    }

    /**
     * 查看关于我的信息
     * @return
     */
    @VisitLogger(value = "关于")
    @ApiOperation(value = "查看关于我信息")
    @GetMapping("/about")
    public ResponseResult<String> getAbout(){
        return ResponseResult.success(blogInfoService.getAbout());
    }
}
